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 
10 	0 	0 	0 	0 	0 	0 	0 	 0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0	10 
10 	0 	0 	0 	0 	0 	0 	0 	 0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0	10 
10 	0 	0 	0 	0 	0 	0 	0 	 0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0	10 
10 	0 	0 	0 	0 	0 	0 	0 	 0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0	10 
10 	0 	0 	0 	0 	0 	0 	0 	 0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0	10 
10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10 	10	10 


*/


package q2d.common.models;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

import q2d.client.renderers.GFactory;

/** Map:
 * 
 * Klasa reprezentujaca mape na ktorej toczy sie rozgrywka.
 */
public class Map {

	/* Wymiary mapy */
	public static final int ROWS = 25;
	public static final int COLS = 25;
	public static final int X_RANGE_BLUE_START =19;
	public static final int X_RANGE_BLUE_END =24;
	public static final int Y_RANGE_BLUE_START =1;
	public static final int Y_RANGE_BLUE_END =6;
	
	public static final int X_RANGE_RED_START =1;
	public static final int X_RANGE_RED_END =9;
	public static final int Y_RANGE_RED_START =19;
	public static final int Y_RANGE_RED_END =24;

	public static final int RED_FLAG_HOME_X = 21*GFactory.TILE_WIDTH + GFactory.TILE_WIDTH/2 - 13;
	public static final int RED_FLAG_HOME_Y = 2*GFactory.TILE_HEIGHT + GFactory.TILE_HEIGHT/2 - 5;
	public static final int BLUE_FLAG_HOME_X = 2*GFactory.TILE_WIDTH + GFactory.TILE_WIDTH/2 - 13;;
	public static final int BLUE_FLAG_HOME_Y = 21*GFactory.TILE_HEIGHT + GFactory.TILE_HEIGHT/2 - 5;
	
	private int[][] tiles;
	private String mapPath = "assets/Map/map.txt";

	public Map(){
		tiles = new int[ROWS][COLS];

		try{
			loadMap();
		}
		catch(Exception e){
			System.out.println("Map file was not found.");
		}

	}

	public void loadMap() throws FileNotFoundException{
		
		String number;
		FileReader fileReader = new FileReader(mapPath);
		Scanner file = new Scanner(fileReader);
		
		for(int i = 0; i < ROWS; i++){
			for(int j =0; j< COLS; j++){
				
				number = file.next();
			    int tileType = Integer.parseInt(number);
			    tiles[i][j] = tileType;				
			}
		
		}
	}
	
	/**
	 * Zwraca rodzaj kafelka na pozycji x, y.
	 * @param x
	 * @param y
	 * @return
	 */
	public int getTile(int x, int y){
		return tiles[y][x];
	}
}
